Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

190
Views
jsPDF jQuery.Deferred exception: r[o] is undefined

I am trying to use jsPDF to download a PDF version of my website. I am getting this error jQuery.Deferred exception: r[o] is undefined. I think it has to do with "var source = $("#content")[0]" in the body somehow being undefined, but I'm not sure if this is the only problem.

Necessary Imports (in head):

    <!-- jQuery library -->
  <script src="static/js/jquery.min.js"></script>

  <!-- jsPDF library -->
  <script src="static/js/jsPDF-1.3.2/dist/jspdf.min.js"></script>

/* Bootstrap at end of body */
  <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.0/dist/js/bootstrap.bundle.min.js" integrity="sha384-U1DAWAznBHeqEIlVSCgzq+c9gqGAJn5c/t99JyeKa9xxaYpSvHU5awsuZVVFIhvj" crossorigin="anonymous"></script>

HTML

<div class="container-fluid" id="content">
    <div class="row">
        <h1>UH ENERGY</h1>
    </div>
    <div class="row">
        <a href="#" id="downloadPDF" >Download PDF</a>
    </div>
    <!--CHART 1-->
    <div class="row">
        <div class="col-md-6 col-sm-12 col-xs-12">
            <canvas id="myChart" class="bar-chart"></canvas>
    <!-- Continued -->

function in main.py

$( document ).ready(function() {
    var doc = new jsPDF(); 
    var specialElementHandlers = {
        "#bypassme": function (element, renderer) {
            return true
        }
    }; 
    var margins = {
        top: 80,
        bottom: 60,
        left: 40,
        width: 522
    }; 
    var source = $("#content")[0];
    doc.fromHTML(
        source.innerHTML,
        margins.left, 
        margins.top, 
        {
            "width": margins.width,
            "elementHandlers": specialElementHandlers
        }, 
        function (dispose) { 
            doc.save("ICEV-EV.pdf"); 
        }, 
        margins
    ); 
    });
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!